//清空
 function cleanFile(){
	var file = $("#uploadtest");
	file.after(file.clone().val(""));      
	file.remove();  
}
//上传
function insertTitle(obj){  
			path=$(obj).prev().val();
		   var test1 = path.lastIndexOf("\\");  //对路径进行截取
 		   var test2 = path.lastIndexOf(".");  //对路径进行截取
 		   var fileName = path.substring(test1+1,test2);
 		   var suffix = path.substring(test2+1,path.length);
 		   
 		   	var KB = 1024;
 		   	var MB = 1024*1024;
 		   	var GB = 1024*1024*1024;
 		   	
 		 	var fileId = "uploadtest";
 		 	var dom = document.getElementById(fileId);  
 		 	var fileSize ="";
 		 	fileSize =  dom.files[0].size;//文件的大小，单位为字节B
 		   if (fileSize === 0) return '0 B';
 		    var k = 1000, // or 1024
 		    sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
 		    i = Math.floor(Math.log(fileSize) / Math.log(k));
 		   fileSize = (fileSize / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
		   var test= Math.max(test1, test2)
		     var tr = "<tr class = 'delAll' onclick='setTable(this)'>"+
				"<td>"+fileName+"</td>"+
				"<td>"+suffix+"</td>"+
				"<td>"+fileSize+"</td>"+
			"</tr>";
			
 		   $(".uploadTable").append(tr)
 		   var wenjian=fileName+"."+suffix;
 		   $("#upladName").val(wenjian);
		}  
var selected="";
function setTable(obj){
	selected = obj;
	$(".uploadTable tr").each(function(i,dom){
		$(dom).css("background-color","white");
		$(dom).removeAttr("data-type");
	})
	
	$(obj).css("background-color", "gainsboro");
	$(obj).attr("data-type","xsg");
	
	var tr = $(".uploadTable tr[data-type=xsg]");
	

}




$(function(){
	$("#delAll").click(function(){
		$(".delAll").empty();
	});
	$("#delOne").click(function(){
//		setTable(obj);
		$(selected).empty();
	});
	$("#refihe").click(function(){
		$(".uploadPop").show(500);
		$("body").addClass("overHiden");
		$(".delAll").empty();
	});
	
	
	
});








